package com.config;

/**
 * @author XiaoHao
 * @date 2021-03-18 10:06
 */
public class DataSourceContextHolder {
    //默认数据源
    public static final String DEFAULT_DS="db";
    public static final ThreadLocal<String> contextHolder = new ThreadLocal<>();

    /**
     * 设置数据源名
     * @param dbType
     */
    public static void setDB(String dbType){
        contextHolder.set(dbType);
    }

    /**
     * 获取数据源名
     * @return
     */
    public static String getDB(){
        return contextHolder.get();
    }

    /**
     * 清除数据源名
     *
     */
    public static void clearDB(){
        contextHolder.remove();
    }
}
